package cn.itcast.web.controller.stat;

import cn.itcast.service.stat.StatService;
import cn.itcast.web.controller.BaseController;
import com.alibaba.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/stats")
public class StatsController extends BaseController {

    // 注入dubbo的服务接口的代理对象
   @Reference
    private StatService statService;



    /**
     * 进入统计分页页面
     *http://localhost:8080/stat/toCharts.do?chartsType=factory 生产厂家销售统计
     *http://localhost:8080/stat/toCharts.do?chartsType=sell
     *http://localhost:8080/stat/toCharts.do?chartsType=online
     */


    @RequestMapping("/toCharts")
    public String toCharts(String chartsType){
        return "stat/stat-"+chartsType;
    }

    // 生产厂家销售统计, 返回json格式
   @RequestMapping("/address")
    @ResponseBody
   public List<Map<String, Object>> address(){
        List<Map<String, Object>> list = statService.address();
        return list;
    }
}

